﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace lcs.Web.bidmaterialinfo
{
    public partial class Add : Web.Admin.BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                lcs.BLL.pmtypeinfo pmbll = new BLL.pmtypeinfo();
                DataSet ds = pmbll.GetList("pmid>0");
                ddlmtype.DataSource = ds;
                ddlmtype.DataTextField = "pmtype";
                ddlmtype.DataValueField = "pmid";
                ddlmtype.DataBind();
                Page.DataBind();
            }

        }

        protected void btnSave_Click(object sender, EventArgs e)
        {

            string strErr = "";
            if (this.txtmbm.Text.Trim().Length == 0)
            {
                strErr += "编码不能为空！\\n";
            }
            if (!PageValidate.IsDecimal(txtmprice.Text))
            {
                strErr += "价格格式错误！\\n";
            }           

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string mbm = this.txtmbm.Text;
            decimal mprice = decimal.Parse(this.txtmprice.Text);
            int mtype =int.Parse( this.ddlmtype.SelectedValue.ToString());

            lcs.Model.bidmaterialinfo model = new lcs.Model.bidmaterialinfo();
            model.mbm = mbm;
            model.mprice = mprice;
            model.mtype = mtype;

            lcs.BLL.bidmaterialinfo bll = new lcs.BLL.bidmaterialinfo();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功,请继续增加！", "Add.aspx");

        }


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("List.aspx");
        }
    }
}
